<extend name="Public:company_center"/>
<block name="right_main">
<div class="wei-user-admin-title-bar">
	<div id="apply-tab" class="container-nav-tabs-2">
		<ul class="nav nav-tabs-2" role="tablist">
			<li
			<empty name='Think.get.status'>class="active"</empty>
			><a href="{:U('Apply/index')}">全部简历</a></li>
			<li
			<eq name='Think.get.status' value="1">class="active"</eq>
			><a
				href="{:U('Apply/index?status=1')}">未处理简历&nbsp;<span
				class="text-highlight"></span></a></li>
			<li
			<eq name='Think.get.status' value="3">class="active"</eq>
			><a href="{:U('Apply/index?status=3')}">已通知面试&nbsp;<span
				class="text-default"></span></a></li>
			<li
			<eq name='Think.get.status' value="4">class="active"</eq>
			><a href="{:U('Apply/index?status=4')}">已发offer</a></li>
			<li
			<eq name='Think.get.status' value="7">class="active"</eq>
			><a href="{:U('Apply/index?status=7')}">不合适简历</a></li>
		</ul>
	</div>
</div>
<div class="hidden">
	<div class="status_1">
		<span class="status-x"><a class="text-primary" href="javascript:;">简历未读</a></span>
			<span class="action-x">
				<a class="btn btn-default btn-sm interview" data-status="3">
					<i class="fa fa-bullhorn"></i>&nbsp;通知面试
				</a>
				<a class="btn btn-default btn-sm action" data-status="7">
					<i class="fa fa-times"></i>&nbsp;不合适
				</a>
			</span>
	</div>
	<div class="status_2">
		<span class="status-x"><span class="label label-success">简历已读</span></span>
			<span class="action-x">
				<a class="btn btn-default btn-sm interview" data-status="3">
					<i class="fa fa-bullhorn"></i>&nbsp;通知面试
				</a>
				<a class="btn btn-default btn-sm action" data-status="7">
					<i class="fa fa-times"></i>&nbsp;不合适
				</a>
			</span>
	</div>
	<div class="status_3">
		<span class="status-x"><span class="label label-success">已通知面试</span></span>
			<span class="action-x">
			<div class="btn-group"><a class="dropdown-toggle btn btn-default" data-toggle="dropdown"><i class="fa fa-gear"></i>&nbsp;操作菜单&nbsp;<i class="icon-caret-down"></i></a>
				<ul class="dropdown-menu btn-group-share">
					<li><a class="action" data-status="7">
						<i class="fa fa-times"></i>&nbsp;不合适
					</a>
					</li>
					<li><a class=" interview" data-status="4">
						<i class="fa fa-send-o"></i>&nbsp;发送offer
					</a>
					</li>
				</ul>
			</div>
			</span>
	</div>
	<div class="status_4">
		<span class="status-x"><span class="label label-success">待回应offer</span></span>
			<span class="action-x">
			<div class="btn-group"><a class="dropdown-toggle btn btn-default" data-toggle="dropdown"><i class="fa fa-gear"></i>&nbsp;操作菜单&nbsp;<i class="icon-caret-down"></i></a>
				<ul class="dropdown-menu btn-group-share">
					<li>
						<a class=" action" data-status="5">
							<i class="fa fa-check"></i>&nbsp;接受offer
						</a>
					</li>
					<li>
						<a class=" action" data-status="6">
							<i class="fa fa-times"></i>&nbsp;拒绝offer
						</a>
					</li>
				</ul>
			</div>
			</span>
	</div>
	<div class="status_5">
		<span class="status-x"><span class="label label-primary">已接受offer</span></span>
			<span class="action-x">
			<div class="btn-group"><a class="dropdown-toggle btn btn-default" data-toggle="dropdown"><i class="fa fa-gear"></i>&nbsp;操作菜单&nbsp;<i class="icon-caret-down"></i></a>
				<ul class="dropdown-menu btn-group-share">
					<li>
						<a class=" action" data-status="6">
							<i class="fa fa-times"></i>&nbsp;拒绝offer
						</a>
					</li>
				</ul>
			</div>
			</span>
	</div>
	<div class="status_6">
		<span class="status-x"><span class="label label-default">已拒绝offer</span></span>
			<span class="action-x">
			<div class="btn-group"><a class="dropdown-toggle btn btn-default" data-toggle="dropdown"><i class="fa fa-gear"></i>&nbsp;操作菜单&nbsp;<i class="icon-caret-down"></i></a>
				<ul class="dropdown-menu btn-group-share">
					<li>
						<a class=" action" data-status="5">
							<i class="fa fa-check"></i>&nbsp;接受offer
						</a>
					</li>
				</ul>
			</div>
			</span>
	</div>
	<div class="status_7">
		<span class="status-x"><span class="label label-default">简历不合格</span></span>
			<span class="action-x">
			<div class="btn-group"><a class="dropdown-toggle btn btn-default" data-toggle="dropdown"><i class="fa fa-gear"></i>&nbsp;操作菜单&nbsp;<i class="icon-caret-down"></i></a>
				<ul class="dropdown-menu btn-group-share">
					<li><a class="interview" data-status="3">
						<i class="fa fa-bullhorn"></i>&nbsp;通知面试
					</a></li>
				</ul>
			</div>
			</span>
	</div>
</div>
<table id="apply-list" class="table table-striped table-hover">
	<thead>
	<tr>
		<th>职位名称</th>
		<th style="width:100px;">个人简历</th>
		<th style="width:80px;">性别</th>
		<th style="width:80px;">年龄</th>
		<th style="width:80px;">学历</th>
		<th style="width:80px;">经验</th>
		<th>投递时间</th>
		<th>状态</th>
		<th>操作</th>
	</tr>
	</thead>
	<tbody>
	<foreach name="apply" item="v">
		<tr class="id" data-id="{$v.id}">
			<td style="white-space:nowrap;"><a class="text-primary" href="{:U('Home/Job/item?jobid='.$v['jid'])}" target="_blank" title="{$v.jobname}">{$v.jobname}</a></td>
			<td><a class="text-primary" href="{:U('User/Preview/index?uid='.$v['uid'].'&id='.$v['id'])}" target="_blank">{$v.info.truename}</a>
			</td>
			<td>
				<eq name='v.info.sex' value="1">男
					<else/>
					女
				</eq>
			</td>
			<td>{:age(date('Ymd',$v['info']['birthday']))}</td>
			<td>{$v.edu}</td>
			<td>{$v.year}</td>
			<td style="white-space:nowrap;">{:tranTime($v['addtime'])}</td>
			<td class="v_status">
				<switch name="v.status">
					<case value="1">
						<a class="text-primary" href="javascript:;">简历未读</a></case>
					<case value="2">
						<span class="label label-success">简历已读</span>
					</case>
					<case value="3">
						<span class="label label-success">已通知面试</span>
					</case>
					<case value="4">
						<span class="label label-success">待回应offer</span>
					</case>
					<case value="5">
						<span class="label label-primary">已接受offer</span>
					</case>
					<case value="6">
						<span class="label label-default">已拒绝offer</span>
					</case>
					<case value="7">
						<span class="label label-default">简历不合格</span>
					</case>
					<default/>
					默认情况
				</switch>
			<td style="white-space:nowrap;" class="v_action">
				<switch name="v.status">
					<case value="1|2">
						<a class="btn btn-default btn-sm interview" data-status="3">
							<i class="fa fa-bullhorn"></i>&nbsp;通知面试
						</a>
						<a class="btn btn-default btn-sm action" data-status="7">
							<i class="fa fa-times"></i>&nbsp;不合适
						</a>

					</case>
					<case value="3">
						<div class="btn-group"><a class="dropdown-toggle btn btn-default" data-toggle="dropdown"><i class="fa fa-gear"></i>&nbsp;操作菜单&nbsp;<i class="icon-caret-down"></i></a>
							<ul class="dropdown-menu btn-group-share">
								<li><a class="action" data-status="7">
									<i class="fa fa-times"></i>&nbsp;不合适
								</a>
								</li>
								<li><a class="interview" data-status="4">
									<i class="fa fa-send-o"></i>&nbsp;发送offer
								</a>
								</li>
							</ul>
						</div>
					</case>
					<case value="4">
						<div class="btn-group"><a class="dropdown-toggle btn btn-default" data-toggle="dropdown"><i class="fa fa-gear"></i>&nbsp;操作菜单&nbsp;<i class="icon-caret-down"></i></a>
							<ul class="dropdown-menu btn-group-share">
								<li>
									<a class=" action" data-status="5">
										<i class="fa fa-check"></i>&nbsp;接受offer
									</a>
								</li>
								<li>
									<a class=" action" data-status="6">
										<i class="fa fa-times"></i>&nbsp;拒绝offer
									</a>
								</li>
							</ul>
						</div>
					</case>
					<case value="5">
						<div class="btn-group"><a class="dropdown-toggle btn btn-default" data-toggle="dropdown"><i class="fa fa-gear"></i>&nbsp;操作菜单&nbsp;<i class="icon-caret-down"></i></a>
							<ul class="dropdown-menu btn-group-share">
								<li>
									<a class=" action" data-status="6">
										<i class="fa fa-times"></i>&nbsp;拒绝offer
									</a>
								</li>
							</ul>
						</div>
					</case>
					<case value="6">
						<div class="btn-group"><a class="dropdown-toggle btn btn-default" data-toggle="dropdown"><i class="fa fa-gear"></i>&nbsp;操作菜单&nbsp;<i class="icon-caret-down"></i></a>
							<ul class="dropdown-menu btn-group-share">
								<li>
									<a class=" action" data-status="5">
										<i class="fa fa-check"></i>&nbsp;接受offer
									</a>
								</li>
							</ul>
						</div>
					</case>
					<case value="7">
						<div class="btn-group"><a class="dropdown-toggle btn btn-default" data-toggle="dropdown"><i class="fa fa-gear"></i>&nbsp;操作菜单&nbsp;<i class="icon-caret-down"></i></a>
							<ul class="dropdown-menu btn-group-share">
								<li><a class="interview" data-status="3" >
									<i class="fa fa-bullhorn"></i>&nbsp;通知面试
								</a></li>
							</ul>
						</div>
					</case>
				</switch>
			</td>
		</tr>
	</foreach>
	</tbody>
	<script>
		seajs.use(["$", 'bootbox'], function ($) {
			$(document).on('click', 'a.action', function () {
				var ob = $(this);
				var id = ob.parents('tr.id').attr('data-id');
				var status = $(this).attr('data-status');
				$.ajax({
					url : "{:U('Apply/update')}",
					data : {id : id, status : status},
					type : "post",
					success : function (data) {
						if ( data.status > 0 ) {
							var status_x = $("div.status_" + status).find("span.status-x").html();
							var action_x = $("div.status_" + status).find("span.action-x").html();
							ob.parents("tr").find("td.v_status").html(status_x);
							ob.parents("tr").find("td.v_action").html(action_x);
						}
						bootbox.alert({
							message : data.info,
							title : "提示信息"
						});

					}
				})
			})
		})
	</script>
</table>
<empty name="apply">
	<div class="image-tip-cry">暂时没有符合条件的简历啊 %&gt;_&lt;%</div>
</empty>
<div class="page hidden">
	{$page}
</div>
<script>

	seajs.use(['$', 'form-ajax'], function ($) {
		//send Mail
		$(document).on('click','a.interview',function () {
			var ob = $(this);
			var id = ob.parents('tr.id').attr('data-id');
			var status = $(this).attr('data-status');
			$.ajax({
				url : "{:U('Apply/interviewForm')}",
				data : {id : id, status :status},
				success : function (data) {
					$("div.mail").html(data);
					$("#modal").modal("show");
					$(document).off("click", "button.js-btn-send");
					$(document).on('click', 'button.js-btn-send', function () {
						$(this).addClass("disabled ").text('处理中...');
						var ajaxFrom = $('#ajaxForm');
						$.ajax({
							url : "{:U('Apply/sendMail')}",
							data : ajaxFrom.serialize(),
							success : function (data) {
								if ( data.status > 0 ) {
									$("div#modal").modal("hide");
									bootbox.alert(data.info);
									var status_x = $("div.status_" + status).find("span.status-x").html();
									var action_x = $("div.status_" + status).find("span.action-x").html();
									ob.parents("tr").find("td.v_status").html(status_x);
									ob.parents("tr").find("td.v_action").html(action_x);

								}

							}
						})

					})
				}
			});

		})
	})
</script>
<!-- 面试邀请 Modal -->
<div class="mail">

</div>
</block>
